<?php
/*
	分红中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$this->session('footernav','');
if($_RQ['op']=='main'){
	//$_SESSION['uid']=5131;
	$return['ischecklogin']=model('jy_weishop/member')->checklogin('','','','',true);
	$return['registerurl']=$return['pluginset']['app_saleurl']?:'';
	$_SESSION['forward_url']='jy_kongtiaoshop/member.index/';
	$_SESSION['logout_forward']='jy_kongtiaoshop/member.index/';
	$return['pluginset']=$this->setting;
	$return['xieyi']=plugin('jy_kongtiaoshop')->plugin_setting('xieyi');
	set_html('title',$return['setting']['title']?:'分红中心');
	$member=model('core/member')->basic($_SESSION['uid']);
	$member['username']=$_SESSION['member']['username'];
	$return['member']=$member;
	$data=array();
	$data['balance_num']=pdo_count('core_member_cash',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$data['credit2inall']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit2inday']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	$data['credit2outall']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit2outday']=pdo_getsum('core_credit_log',array('type'=>2,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	$data['credit3inall']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit3inday']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	$data['credit3outall']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$data['credit3outday']=pdo_getsum('core_credit_log',array('type'=>3,'is_add'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'fee');
	foreach($data as &$row){
		$row=price($row);
	}
	$return['data']=$data;
	//公告列表
	$pindex = max(1, intval($post['page']));
	$psize = 10;
	$total='';
	$notice_list = pdo_getslice('jy_weishop_notice',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array($pindex,20),$total,array('id','title','createtime'),'','id desc');
	if($notice_list){
		foreach($notice_list as &$notice){
			$notice['createtime']=date('Y-m-d h:i',$notice['createtime']);
		}
	}
	$return['notice_list']=$notice_list;
	$status0 = pdo_count('jy_weishop_order',array('plugin_name'=>'jy_kongtiaoshop','uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>0,'deleted'=>0,'userdeleted'=>0));
	$status1 = pdo_count('jy_weishop_order',array('plugin_name'=>'jy_kongtiaoshop','uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1,'deleted'=>0,'userdeleted'=>0));
	$status2 = pdo_count('jy_weishop_order',array('plugin_name'=>'jy_kongtiaoshop','uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>2,'deleted'=>0,'userdeleted'=>0));
	$status3 = pdo_count('jy_weishop_order',array('plugin_name'=>'jy_kongtiaoshop','uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>3,'iscomment'=>0,'deleted'=>0,'userdeleted'=>0));
	$cartnums= pdo_getsum('jy_weishop_member_cart',array('mid'=> $_SESSION['uid'], 'uniacid' => $_SESSION['uniacid']),'total');
	$return['statics']=array(
			'status0'=>$status0,
			'status1'=>$status1,
			'status2'=>$status2,
			'status3'=>$status3,
			'cartnums'=>$cartnums
	);
	$return['mymembers']=pdo_getall('core_members',array('id <>'=>$_SESSION['uid'],'mobile'=>$member['mobile'],'uniacid'=>$_SESSION['uniacid']),array('id','username'));
	$return['shopset']=plugin('jy_weishop')->plugin_setting('shopset');
	exi($return);
}
?>